﻿@model List<CompanyManagementDLL.MetaData.UserMetaData>

@{
    ViewBag.Title = "User";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-header">
                <h3 class="box-title">User Management</h3>
            </div>
            <div class="box-body table-responsive">
                <div style="margin-bottom: 2%">
                    <a href="@Url.Action("Create", "User")" class="btn btn-success"><i class="fa fa-plus"></i>Add User</a>
                </div>
                <table class="table table-bordered table-hover dataTable">
                    <thead>
                        <tr>
                            <th>User Name</th>
                            <th>Role Name</th>
                            <th>EmailID</th>
                            <th>Full Name</th>
                            <th>Contact No</th>
                            <th>Address</th>
                            <th>LastLogin</th>
                            <th>Is Active</th>
                            <th>Action</th>
                        </tr>
                    </thead>
                    @if (Model.Count > 0 && Model != null)
                    {
                        <tbody>
                            @foreach (var item in Model)
                            {
                                <tr>
                                    <td>@item.UserName</td>
                                    @{item.RoleName = new CompanyManagementDLL.DLL.RoleDLL().GetRoleByID(item.RoleID.Value).RoleName;}
                                    <td>@item.RoleName</td>
                                    <td>@item.EmailID</td>
                                    <td>@item.FullName</td>
                                    <td>@item.PhoneNumber</td>
                                    <td>@item.Address</td>
                                    <td>@item.LastLoginDate</td>
                                    <td>@Html.CheckBox("IsActive", item.IsActive, new { disabled = "disabled" })</td>
                                    <td>
                                        <a href="~/User/Edit?Id=@item.UserID"><i class="fa fa-edit"></i>Edit </a>
                                        @if (item.UserID != CompanyManagement.Utility.getUserID())
                                        {
                                            <a href="@Url.Action("Delete", "User", new { id = item.UserID })" onclick="return confirm('Are sure want to Delete?')"><span style="margin-right: 4%">|</span><i class="fa fa-trash"></i>Delete </a>
                                        }
                                    </td>
                                </tr>
                            }
                        </tbody>
                    }
                </table>
            </div>
        </div>
    </div>
</div>

<script>
    $("#pagetitle").html("User");

</script>